﻿using System;
using System.Collections.Generic;
using RayDen.Library.Components;
using RayDen.Library.Components.Color;
using RayDen.Library.Components.SystemComponents;
using RayDen.Library.Core;
using RayDen.Library.Core.Primitives;
using RayDen.RayEngine.Core.Types;
using RayDen.RayEngine.Data;
using RayDen.RayEngine.Samplers;

namespace RayDen.RayEngine.NextGen
{
    public class PathSampler
    {
        protected internal int RayIndex;
        protected internal RayData PathRay;

        public IRadianceEvaluation Radiance;
        public Sample Sample;

        internal SurfaceSampler SurfaceSampler;

        internal List<RayData> secondaryRays;

        protected int Depth;

        public virtual void InitPath(PathIntegrator buffer)
        {
            if (secondaryRays == null)
                secondaryRays = new List<RayData>();
            else 
                secondaryRays.Clear();
        }

        
        public virtual bool FillRayBuffer(RayBuffer rayBuffer)
        {
            return false;
        }
        public virtual void Advance(RayBuffer rayBuffer, SampleBuffer consumer, Action<PathSampler> onRestart)
        {
            
        }

        public virtual void Splat(SampleBuffer sampleBuffer)
        {

            RgbSpectrum color;
            this.Radiance.ToRgbSpectrum(out color);
            sampleBuffer.SplatSample(this.Sample.imageX, this.Sample.imageY, ref color);
        }


        protected static void Print(string msg)
        {
#if VERBOSE
            Tracer.TraceLine(msg);
#endif

        }
    }
} 